﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;

public class UIManager : MonoBehaviour
{
    static UIManager instance;

    public TextMeshProUGUI orbText, timeText, deathText, gameOver;


    private void Awake()
    {
        if (instance != null)
        {
            Destroy(gameObject);
            return;
        }
        instance = this;

        DontDestroyOnLoad(this);
    }


    public static void UpdateOrbUI(int orbCount) 
    {
        instance.orbText.text = orbCount.ToString();
    }

    public static void UpdateDeathUI(int deathCount) 
    {
        instance.deathText.text = deathCount.ToString();
    }

    public static void UpdateTimeUI(float time) 
    {
        int minutes = (int)(time / 60);
        float seconds = time % 60;

        instance.timeText.text = minutes.ToString("00") + " : " + seconds.ToString("00");
        
    }

    public static void DisplayWin() 
    {
        instance.gameOver.text = "YOU WIN!";

        instance.gameOver.enabled = true;
    }

    public static void DisplayGameOver()
    {
        instance.gameOver.text = "Game Over";

        instance.gameOver.enabled = true;
    }

    public static void CloseGameOver() 
    {
        instance.gameOver.enabled = false;
    }
}
